package com.why.blog.controller;

import com.why.blog.bean.Blog;
import com.why.blog.service.BlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: blog
 * @description:
 * @author: @why
 * @create: 2021-01-22 09:48
 **/
@Controller
public class archiveController {

    @Autowired
    BlogService blog;
    @GetMapping("/archive")
    public String archiveBlog(Model model){
        Map<String, List<Blog>> blogByYear = blog.getBlogByYear();
        model.addAttribute("years",blogByYear);
            return  "archive";
    }
}
